;;; init.el -*- lexical-binding: t; -*-

;; Emacs start with other configuraction file instead of `~/.emacs.d/init.el` should include below codes.
;; `emacs -q -l location/of/init.el`
(setq user-emacs-directory (file-name-directory (or load-file-name buffer-file-name)))
(setq user-init-file (expand-file-name "init.el" user-emacs-directory))

(setq custom-file (locate-user-emacs-file "custom.el"))
(load-file custom-file)

(defvar mkmk-cache-dir (locate-user-emacs-file ".cache") "Cache directory which will not under version controll.")

;; package
(setq package-user-dir (expand-file-name "elpa" mkmk-cache-dir))
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                         ("melpa" . "http://melpa.org/packages/")))
(package-initialize)

;; UI
(menu-bar-mode 0)
(tool-bar-mode 0)
(scroll-bar-mode -1)
(add-to-list 'default-frame-alist '(fullscreen . maximized))

;; file encoding
(prefer-coding-system 'utf-8)

;; backup
(setq make-backup-files nil) ; stop creating backup~ files
(setq auto-save-default nil) ; stop creating #autosave# files

(eval-when-compile
  ;; Following line is not needed if use-package.el is in ~/.emacs.d
  (unless (package-installed-p 'use-package)
    (package-refresh-contents)
    (package-install 'use-package))
  (require 'use-package))

(use-package all-the-icons
  :ensure t)

(use-package evil
  :ensure t
  :config
  (evil-mode 1))

(use-package company
  :ensure t
  :config
  (global-company-mode))

(use-package badwolf-theme
  :ensure t
  :config
  (load-theme 'badwolf 'no-confirm))

(use-package php-mode
  :ensure t
  :config
  (require 'php-mode))

(use-package smartparens
  :ensure t)

(use-package evil-smartparens
  :ensure t)

(use-package helm
  :ensure t
  :bind (("M-x" . helm-M-x)
         ("M-<f5>" . helm-find-files)
         ([f10] . helm-buffers-list)
         ([S-f10] . helm-recentf)))

(defun mkmk-find-user-init-file ()
  "Edit 'init.el'."
  (interactive)
  (find-file user-init-file))
